package cn.iocoder.yudao.module.test.controller.admin.bpmPurchaseOrderDemo;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.test.controller.admin.bpmPurchaseOrderDemo.vo.BpmPurchaseOrderDemoInstanceVO;
import cn.iocoder.yudao.module.test.dal.dataobject.bpmPurchaseOrderDemo.BpmPurchaseOrderDemoDO;
import cn.iocoder.yudao.module.test.service.BpmPurchaseOrderDemoService;
import cn.iocoder.yudao.module.test.service.BpmPurchaseOrderDemoServiceImpl;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
import javax.annotation.Resource;

/**
 * @Author cjc
 * @Date 2024/1/11 16:45
 * @Description: 订单业务-模拟审批流程
 * @Version 1.0
 */
@Tag(name = "管理后台 - 订单审批 - 审批流demo")
@RestController
@RequestMapping("/bpm/purchase/order/demo")
@Validated
public class BpmPurchaseOrderDemoController {

    @Resource
    private BpmPurchaseOrderDemoService bpmPurchaseOrderDemoService;


    @GetMapping("test")
    public String test(){
        return "hello order.";
    }

    @PostMapping("create")
    public CommonResult<Long> createOrder(@RequestBody BpmPurchaseOrderDemoDO purchaseOrderDO){
        return success(bpmPurchaseOrderDemoService.createOrder(purchaseOrderDO));
    }

    @PostMapping("createBpm")
    @Transactional(rollbackFor = Exception.class)
    public CommonResult<String> createBpm(@RequestBody BpmPurchaseOrderDemoInstanceVO instanceVO){
        return success(bpmPurchaseOrderDemoService.createBpm(instanceVO));
    }


}
